extension StringExt on String? {
  bool get isNullOrEmpty => this == null ? true : this!.trim().isEmpty;

  String? get replaceBreak => (this == null || this!.isEmpty)
      ? this
      : this!.replaceAll(RegExp("\\s{2,}|\t|\r|\n"), '\n');

  ///
  /// replace %%s
  ///
  String? replacePercentS(List<String?> strList) {
    if (isNullOrEmpty) {
      return this;
    }
    if (strList.length == 1) {
      return this!.replaceAll(RegExp("%%s"), strList.first ?? "");
    } else {
      for (var element in strList) {
        this!.replaceFirstMapped("%%s", (match) => element!);
      }
      return this;
    }
  }

  String replaceWord(bool isSelf) {
    if (this == null || this!.isEmpty) {
      return '';
    }
    if (isSelf) {
      return this!;
    }

    String temp = this!;

    var women = [
      "sugar baby",
      "sugarbaby",
      "suger baby",
      "sugar babies",
      "sugar mommy",
      "sugar momma",
      "sugar mama",
      "sugar mummies",
      "sugar mommas",
      "sugar mamas",
      "sugarmummies",
      "sugarmommies",
      "sugarmamas"
    ];

    var man = [
      "sugar daddy",
      "sugardaddy",
      "suger daddy",
      "sugar daddies",
      "sugardaddies",
      'sugar',
    ];

    for (var element in women) {
      temp = temp.replaceAll(RegExp(element, caseSensitive: false), "*");
    }
    for (var element in man) {
      temp = temp.replaceAll(RegExp(element, caseSensitive: false), "*");
    }
    // ReplaceWordUtil.words.forEach((key, value) {
    //   temp = temp.replaceAll(RegExp(key, caseSensitive: false), value);
    // });
    return temp;
  }
}

extension StringExtension on String {
  ///
  /// test word => Test Word
  ///
  String capitalizeWords() {
    return split(" ")
        .map((word) => "${word[0].toUpperCase()}${word.substring(1)}")
        .join(" ");
  }
}
